import sys, os


fd=os.open(os.environ["FIEM_PIPE_STOR"],os.O_RDWR)
base_dir="/tmp/fiem"
try: os.makedirs(base_dir,0777)
except: pass
while(True):
        ret=os.read(fd,1024)
        l=ret.split(";")
        s=l[0].split("|")
        path1=base_dir
        i=0
        while(i< len(s)):
                path1=path1+'/'+s[i][s[i].index(':')+1:]
                i=i+1


        try: os.makedirs(path1,0777)
        except: pass
        logfile=open(os.path.join(path1,"log"),"a")
        logfile.write(l[1])
        logfile.close()
                
